int totalMoney(int n){
    int temp;
    int temp1;
    int temp2 = 0;
    int answer = 0;
    temp1= n % 7;
    temp = n / 7;
    if (temp >= 1)
    {   
        for (int j = 0; j < temp; j++)
        {
            answer += 28 + j * 7;
        } 
    }
    if (temp1 > 0)
    {   
        for (int i = 0; i < temp1; i++ )
        {
            temp2 += 1 + temp + i;
        }
    }
    return answer + temp2;
}